import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:gourmet/color/hex.dart';
import 'package:gourmet/extensions/ex_widget.dart';
import 'package:gourmet/route/index.dart';
import 'package:gourmet/utils/colors.dart';
import 'package:gourmet/utils/radian.dart';
import 'package:gourmet/utils/styles.dart';

class CancelVerifyController extends GetxController {
  final double navHeight = 44 + Get.mediaQuery.padding.top;
  final double navTop = 44.0;
}

class CancelVerifyPage extends GetView<CancelVerifyController> {
  const CancelVerifyPage({super.key});

  @override
  Widget build(BuildContext context) {
    return MediaQuery.removeViewPadding(
      context: context,
      removeBottom: true,
      removeLeft: true,
      removeRight: true,
      removeTop: true,
      child: Scaffold(
        backgroundColor: Colors.white,
        appBar: PreferredSize(
          preferredSize: Size.fromHeight(controller.navHeight),
          child: AnnotatedRegion<SystemUiOverlayStyle>(
            value: SystemUiOverlayStyle.dark,
            child: Container(
              color: Colors.white,
              height: controller.navHeight,
              padding: Get.mediaQuery.padding,
              child: Stack(
                children: [
                  Positioned(
                    width: 40,
                    height: controller.navTop,
                    top: 0,
                    left: 0,
                    child: Center(
                      child: Icon(
                        CupertinoIcons.chevron_back,
                        size: 20,
                        color: HexColor(ColorsUtils.color0000),
                      ),
                    ).onTap(Get.back),
                  ),
                ],
              ),
            ),
          ),
        ),
        body: SingleChildScrollView(
          padding: EdgeInsets.symmetric(horizontal: (Get.width - 315) / 2),
          child: Column(
            children: [
              Container(
                margin: const EdgeInsets.only(top: 30, bottom: 10),
                alignment: Alignment.centerLeft,
                child: Text(
                  '注销账号',
                  style: StylesUtils.customTextStyle(
                    color: ColorsUtils.color3636,
                    fontSize: StylesUtils.fontSize28,
                  ),
                ),
              ),
              Align(
                alignment: Alignment.centerLeft,
                child: Text.rich(
                  TextSpan(
                    children: [
                      TextSpan(
                        text: '请输入 ',
                        style: StylesUtils.customTextStyle(
                          color: ColorsUtils.color9999,
                          fontSize: StylesUtils.fontSize13,
                        ),
                      ),
                      TextSpan(
                        text: '136****5678',
                        style: StylesUtils.customTextStyle(
                          color: ColorsUtils.color0000,
                          fontSize: StylesUtils.fontSize13,
                        ),
                      ),
                      TextSpan(
                        text: ' 收到的短信验证码，以完成身份验证~',
                        style: StylesUtils.customTextStyle(
                          color: ColorsUtils.color9999,
                          fontSize: StylesUtils.fontSize13,
                        ),
                      ),
                    ],
                  ),
                ),
              ),
              Container(
                alignment: Alignment.centerLeft,
                margin: const EdgeInsets.only(top: 40, bottom: 60),
                child: TextField(
                  cursorHeight: 20,
                  cursorWidth: 3,
                  cursorRadius: const Radius.circular(2),
                  cursorColor: HexColor(ColorsUtils.colorFf64),
                  style: StylesUtils.customTextStyle(
                    fontSize: StylesUtils.fontSize15,
                    color: ColorsUtils.color0000,
                  ),
                  textAlign: TextAlign.left,
                  textAlignVertical: TextAlignVertical.center,
                  textDirection: TextDirection.ltr,
                  decoration: InputDecoration(
                    hintText: '请输入验证码',
                    hintStyle: StylesUtils.customTextStyle(
                      fontSize: StylesUtils.fontSize15,
                      color: ColorsUtils.color9999,
                    ),
                    filled: false,
                    isDense: true,
                    isCollapsed: true,
                    suffixIconConstraints:
                        const BoxConstraints.expand(height: 30, width: 105),
                    suffixIcon: Container(
                      alignment: Alignment.center,
                      decoration: BoxDecoration(
                        border: Border.all(
                          color: HexColor(ColorsUtils.colorFf64),
                        ),
                        borderRadius: BorderRadius.circular(15),
                      ),
                      child: Text(
                        '获取验证码',
                        style: StylesUtils.customTextStyle(
                          color: ColorsUtils.colorFf64,
                        ),
                      ),
                    ).onTap(() {}),
                    contentPadding: const EdgeInsets.symmetric(
                        vertical: 15, horizontal: 10),
                    enabledBorder: UnderlineInputBorder(
                      borderSide: BorderSide(
                        color: HexColor(ColorsUtils.colorF5f5),
                        width: 2,
                      ),
                    ),
                    focusedBorder: UnderlineInputBorder(
                      borderSide: BorderSide(
                        color: HexColor(ColorsUtils.colorF5f5),
                        width: 2,
                      ),
                    ),
                    border: UnderlineInputBorder(
                      borderSide: BorderSide(
                        color: HexColor(ColorsUtils.colorF5f5),
                        width: 2,
                      ),
                    ),
                    constraints:
                        const BoxConstraints.expand(width: 315, height: 50),
                  ),
                ),
              ),
              Center(
                child: Container(
                  constraints:
                      const BoxConstraints.expand(width: 315, height: 45),
                  alignment: Alignment.center,
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(23),
                    gradient: LinearGradient(
                      colors: [
                        ColorsUtils.rgba(255, 153, 0, 1),
                        ColorsUtils.rgba(255, 153, 0, 1),
                        ColorsUtils.rgba(254, 70, 1, 1),
                        ColorsUtils.rgba(254, 70, 1, 1)
                      ],
                      stops: const [
                        0,
                        0,
                        1,
                        1,
                      ],
                      begin: Alignment.topLeft,
                      end: Alignment.bottomRight,
                      transform: GradientRotation(
                        RadianUtils.angleToRadian(90),
                      ),
                    ),
                  ),
                  child: Text(
                    '下一步',
                    style: StylesUtils.customTextStyle(
                      fontSize: StylesUtils.fontSize16,
                    ),
                  ),
                ).onTap(() {
                  Get.toNamed(Routes.mineCancelSuccess);
                }),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
